package ch12;

class ThreadEx01 {
	public static void main(String args[]) {
		ThreadEx01_1 t1 = new ThreadEx01_1();

		Runnable r = new ThreadEx01_2();
		Thread t2 = new Thread(r);

		t1.start();
		t2.start();
	}
}

class ThreadEx01_1 extends Thread {
	public void run() {
		for(int i=0; i < 10; i++) System.out.println(getName());
	}
}

class ThreadEx01_2 implements Runnable {
	public void run() {
		for(int i=0; i < 10; i++) 
			System.out.println(Thread.currentThread().getName());
	}
}
/*
Thread-0
Thread-0
Thread-0
Thread-0
Thread-1
Thread-0
Thread-0
Thread-0
Thread-0
Thread-0
Thread-0
Thread-1
Thread-1
Thread-1
Thread-1
Thread-1
Thread-1
Thread-1
Thread-1
Thread-1

*/